package com.probiz.estore.exports.handler.salesOrder;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;

import com.probiz.estore.core.util.I18nUtil;
import com.probiz.estore.exports.handler.ColumnHandler;
import com.probiz.estore.exports.model.Column;

public class StatusHandler implements ColumnHandler {

	public String getProperty(Object target, Column column, HSSFSheet sheet,
			HSSFRow row, List<String> listHeader) {
		Object obj1 = target;
		Object obj = null;
		String properties[] = column.getAttrName().split("\\.");
		if(properties.length>0){
			for (String propertie : properties) {
				try {
					if(obj1 == null){
						continue;
					}
					obj = PropertyUtils.getProperty(obj1, propertie);
					if(properties.length > 1){
						obj1 = obj;
					}
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				} catch (InvocationTargetException e) {
					e.printStackTrace();
				} catch (NoSuchMethodException e) {
					e.printStackTrace();
				}
				
			}
			obj1 = target;
		}
		return I18nUtil.getInstance().getMessage("salesOrder."+column.getAttrName()+"."+obj.toString());
	}

}
